-
Notifications
You must be signed in to change notification settings - Fork 5
CheckedRegions understand return types, fixes #263 #357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (isTopLevel(Context, S)) { | ||
const auto &Parents = Context->getParents(*S); | ||
assert(!Parents.empty()); | ||
FunctionDecl* Parent = const_cast<FunctionDecl*>(Parents[0].get<FunctionDecl>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does Parent
need to be non-const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because ProgramInfo::getVariable
takes a non-const
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be able to make the parameter of getVariable
const
. We should rarely if ever be mutating this sort of clang AST node object. Perhaps not as part of this PR, but in a later change we could add const
annotations to these AST node objects where we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'm happy to go through and try to make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, per the status meeting: Let's just do this as a separate PR; leave the const_cast
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with this. Per the comment on the PR, change getVariable
's type as part of another PR.
Main question I have is on my
const_cast
at checkedregions.c:173. Is there a way to avoid this, without needing to change the entire project to makeProgramInfo::getVariable
const?